/**
 * 
 */
package xx.teach.entity;

import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.List;

import javax.sql.RowSet;

import xx.db.QueryRunner;
import xx.db.annotation.Column;
import xx.db.annotation.TableName;
import xx.db.sql.Owner;
import xx.db.sql.Table;

/**
 * @author Administrator 2014-3-18
 */
@TableName(name = "t_answer")
public class Answer extends Table
{

    /**
     * @param qr
     * @param owner
     */
    public Answer(QueryRunner qr, Owner owner)
    {
        super(qr, owner);
        // TODO Auto-generated constructor stub
    }

    public static final String ANSWER_ID = "answer_id";

    @Column(name = ANSWER_ID, pk = true)
    private long answerId;

    public static final String JOB_ID = "job_id";

    @Column(name = JOB_ID)
    private long jobId;

    public static final String ACCOUNT_ID = "account_id";

    @Column(name = ACCOUNT_ID)
    private long accountId;

    public static final String SUBMIT_TIME = "submit_time";

    @Column(name = SUBMIT_TIME)
    private Timestamp submitTime;

    public static final String STATUS = "status";

    @Column
    private int status;

    public static final String CONTENT = "content";

    @Column
    private String content;

    public static final String ATTACH_PATH = "attach_path";

    @Column(name = ATTACH_PATH)
    private String attachPath;

    public long getAnswerId()
    {
        return answerId;
    }

    public Answer setAnswerId(long answerId)
    {
        this.answerId = answerId;
        return this;
    }

    public long getJobId()
    {
        return jobId;
    }

    public Answer setJobId(long jobId)
    {
        this.jobId = jobId;
        return this;
    }

    public long getAccountId()
    {
        return accountId;
    }

    public Answer setAccountId(long accountId)
    {
        this.accountId = accountId;
        return this;
    }

    public Timestamp getSubmitTime()
    {
        return submitTime;
    }

    public Answer setSubmitTime(Timestamp submitTime)
    {
        this.submitTime = submitTime;
        return this;
    }

    public int getStatus()
    {
        return status;
    }

    public Answer setStatus(int status)
    {
        this.status = status;
        return this;
    }

    public String getContent()
    {
        return content;
    }

    public Answer setContent(String content)
    {
        this.content = content;
        return this;
    }

    public String getAttachPath()
    {
        return attachPath;
    }

    public Answer setAttachPath(String attachPath)
    {
        this.attachPath = attachPath;
        return this;
    }

    /**
     * 根据jobId获取answer列表
     * 
     * @return
     * @throws SQLException
     */
    public List<Answer> getAnswerByJobId() throws SQLException
    {
        return select.from(Answer.class).where(Answer.JOB_ID + "=" + jobId).go();
    }
    
    public RowSet getUncheckAnswer() throws SQLException{
        return select.from(Answer.class).leftJoin(Job.class, Job.NAME).using(Answer.JOB_ID).where(Answer.STATUS+"="+0).query();
    }
}
